package com.waiting.string;

/**
 * @Description
 * @Author bjweitingting
 * @Date 2019/2/12
 **/
public class StringThreadTest {

    public static void main(String[] args) {
        String test = "这是一个共享的字符串";
        ThreadString thread_1=new ThreadString(test);
        ThreadString thread_2=new ThreadString(test);
        new Thread(thread_1).start();
        new Thread(thread_2).start();
        System.out.println(test);
    }
}

class ThreadString implements Runnable {
    String test;

    ThreadString(String test) {
        this.test = test;
    }

    @Override
    public void run() {
        test = Thread.currentThread().getName();
        System.out.println(test);
    }
}
